<template>
  <el-button v-bind="$attrs" @click="clickBtn">
    <slot ></slot>
  </el-button>
</template>

<script setup>
const emits = defineEmits(['click'])
const props = defineProps({
  // 节流时长
  delay: {
    default: 800,
  }
})

let submitTime = 0;
// 触发点击
function clickBtn(){
  if (props.delay > 0) {
    let now = new Date().getTime();
    if (now - submitTime > props.delay) {
      submitTime = now;
      emits('click');
    }
  } else {
    emits('click')
  }
}


</script>
<style lang="scss" scoped>

</style>
